GetTileImage(Int32,Int32,EventHandler<ProgressEventArgs>) Method (Jpeg2000Page)
In This Topic
Returns an image of specified tile of this page, decoded with the specified number of wavelet levels.
Syntax
Parameters
- tileIndex
- The zero based tile index.
- waveletLevels
- The number of discrete wavelet transformation levels (decomposition levels).
- imageLoadingProgress
- Delegate of the image loading progress. Can be set to null (Nothing in Visual Basic).
Return Value
Scaled image associated with the specified tile.
Exceptions
Remarks
Tile decoded unscaled if waveletLevels equals to WaveletLevels; otherwise, tile decoded with scale (2 in power (WaveletLevels - waveletLevels)).
Example
This C#/VB.NET code shows how to open a JPEG2000 file and get its image by parts.
' Opens JPEG2000 file and gets its image by parts.
Public Shared Function GetJpeg2000ImageByParts(jpeg2000Filename As String) As Vintasoft.Imaging.VintasoftImage
' open an existing JPEG2000 file
Using file As New Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File(jpeg2000Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read)
' get JPEG2000 page
Dim page As Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000Page = file.Page
' get page dimensions and pixel format
Dim imageWidth As Integer = page.Width
Dim imageHeight As Integer = page.Height
Dim palette As Vintasoft.Imaging.Palette = If(page.Palette IsNot Nothing, page.Palette, New Vintasoft.Imaging.Palette())
Dim imageInfo As New Vintasoft.Imaging.Codecs.Decoders.ImageInfo(imageWidth, imageHeight, page.BitsPerPixel, palette, page.Resolution)
Dim pixelFormat As Vintasoft.Imaging.PixelFormat = imageInfo.PixelFormat
' get tiles grid of the page
Dim tilesGrid As System.Drawing.Rectangle() = page.GetTileGrid()
' get tiles count
Dim tileCount As Integer = tilesGrid.Length
' get number of wavelet levels
Dim waveletLevel As Integer = page.WaveletLevels
' create a VintasoftImage object
Dim resultImage As New Vintasoft.Imaging.VintasoftImage(imageWidth, imageHeight, pixelFormat)
' for each tile in page
For i As Integer = 0 To tileCount - 1
' get current rectangle
Dim tileRectangle As System.Drawing.Rectangle = tilesGrid(i)
' get current rectangle location
Dim position As System.Drawing.Point = tileRectangle.Location
' get image of current tile
Using tile As Vintasoft.Imaging.VintasoftImage = page.GetTileImage(i, waveletLevel, Nothing)
' overlay tile on result image
Dim overlayCommand As New Vintasoft.Imaging.ImageProcessing.OverlayCommand(tile, position)
overlayCommand.ExecuteInPlace(resultImage)
End Using
Next
Return resultImage
End Using
End Function
// Opens JPEG2000 file and gets its image by parts.
public static Vintasoft.Imaging.VintasoftImage GetJpeg2000ImageByParts(string jpeg2000Filename)
{
// open an existing JPEG2000 file
using (Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File file =
new Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File(
jpeg2000Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
// get JPEG2000 page
Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000Page page = file.Page;
// get page dimensions and pixel format
int imageWidth = page.Width;
int imageHeight = page.Height;
Vintasoft.Imaging.Palette palette = page.Palette != null ? page.Palette : new Vintasoft.Imaging.Palette();
Vintasoft.Imaging.Codecs.Decoders.ImageInfo imageInfo =
new Vintasoft.Imaging.Codecs.Decoders.ImageInfo(
imageWidth,
imageHeight,
page.BitsPerPixel,
palette,
page.Resolution);
Vintasoft.Imaging.PixelFormat pixelFormat = imageInfo.PixelFormat;
// get tiles grid of the page
System.Drawing.Rectangle[] tilesGrid = page.GetTileGrid();
// get tiles count
int tileCount = tilesGrid.Length;
// get number of wavelet levels
int waveletLevel = page.WaveletLevels;
// create a VintasoftImage object
Vintasoft.Imaging.VintasoftImage resultImage =
new Vintasoft.Imaging.VintasoftImage(imageWidth, imageHeight, pixelFormat);
// for each tile in page
for (int i = 0; i < tileCount; i++)
{
// get current rectangle
System.Drawing.Rectangle tileRectangle = tilesGrid[i];
// get current rectangle location
System.Drawing.Point position = tileRectangle.Location;
// get image of current tile
using (Vintasoft.Imaging.VintasoftImage tile = page.GetTileImage(i, waveletLevel, null))
{
// overlay tile on result image
Vintasoft.Imaging.ImageProcessing.OverlayCommand overlayCommand =
new Vintasoft.Imaging.ImageProcessing.OverlayCommand(tile, position);
overlayCommand.ExecuteInPlace(resultImage);
}
}
return resultImage;
}
}
Requirements
Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
See Also